package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.dao.ZrukuDao;
import cn.gson.fengboot.model.pojos.Zbarter;
import cn.gson.fengboot.model.pojos.Zruku;
import cn.gson.fengboot.model.pojos.Zrukuxq;
import cn.gson.fengboot.model.service.ZchukuService;
import cn.gson.fengboot.model.service.ZrukuService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/ruku")
public class ZrukuController {
    @Autowired
    ZrukuService service;

    //出库单列表查询方法
    @RequestMapping("/list_ruku")
    @ResponseBody
    public Map<String, Object> kaipiao(Integer page, Integer size, String search, String search2) {
        Page<Object> obj = PageHelper.startPage(page, size);
        service.chukuliebiao(search,search2);

        Map<String, Object> map = new HashMap<>();
        map.put("total", obj.getTotal());
        map.put("rows", obj.getResult());
        return map;
    }

    //出库单新增修改
    @RequestMapping("/add")
    @ResponseBody
    public void add(@RequestBody Zruku rk){
        service.add(rk);
    }

    //出库单新增修改
    @RequestMapping("/xqlist")
    @ResponseBody
    public List<Zrukuxq> rukuxq(Integer search){
        return service.rukuxq(search);
    }
}
